package com.example.day24;

/**
 * @author Lenovo
 */
public class ReflectDemo05 {
    public static void main(String[] args) throws  Exception{
        Class<?> c = Class.forName("com.example.day24.Student");
        constructor<?>c =class.forName("com.example.day24.Student");
        Constructor<?> con = c.getConstructor();
        Object obj = con.newInstance();
        System.out.println(obj);
        Field nameField = c.getDeclaredField("name");
        nameField.setAccessible(true);
        nameField.set(obj, "林青霞");
        System.out.println(obj);
        Field ageField = c.getDeclaredField("age");
        ageField.setAccessible(true);
        ageField.set(obj,30);
        System.out.println(obj);
        Field addressField = c.getDeclaredField("address");
        addressField.setAccessible(true);
        addressField.set(obj,"西安");
        System.out.println(obj);


    }
}
